﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Script动作</title>
	<meta charset="utf-8" />
	<link href="../lib/highlight/default.css" rel="stylesheet" />
	<script src="../lib/jquery.js"></script>
	<script src="../lib/highlight.js"></script>
	<script src="../lib/jsm.js"></script>
	<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
	<h1>HTML：</h1>

<input type="button" id="btnHtml" value="点击我" />
<script>
	var btnHtml = document.getElementById("btnHtml");
	btnHtml.addEventListener("click", function(){
		alert("Is me!")
	});
</script>

<pre><code class="html">
&lt;input type="button" id="btnHtml" value="点击我" /&gt;
&lt;script&gt;<code class="javascript">
var btnHtml = document.getElementById("btnHtml");
btnHtml.addEventListener("click", function(){
	alert("Is me!")
});
&lt;/script&gt;
</code>
</code></pre>

	<h1>jsm：</h1>
<script>
jsm
	.input({type:"button",id:"btnjsm",value:"点击我"})()
	(function(){
		var btnJwml = document.getElementById("btnjsm");
		btnJwml.addEventListener("click", function(){
			alert("Is me!");
		})
	})
.render();
</script>

<pre><code class="javascript">
jsm
	.input({type:"button",id:"btnjsm",value:"点击我"})()
	(function(){
		var btnJwml = document.getElementById("btnjsm");
		btnJwml.addEventListener("click", function(){
			alert("Is me!");
		})
	})
.render();
</code></pre>

<br />
<div>不需要ID的input事件：</div>
<script>
jsm
	.input({type:"button",value:"点击我"})()
	(function(btnJwml){
		//这里会计算参数数量，自动填入生成的element
		btnJwml.addEventListener("click", function(){
			alert("Is me!");
		})
	})
.render();
</script>

<pre><code class="javascript">
jsm
	.input({type:"button",value:"点击我"})()
	(function(btnJwml){
		//这里会计算参数数量，自动填入生成的element
		btnJwml.addEventListener("click", function(){
			alert("Is me!");
		})
	})
.render();
</code></pre>

</body>
</html>
